package com.company;

import javax.swing.table.AbstractTableModel;
import java.util.List;

public class RtModel extends AbstractTableModel {

    List<Rt> data;
    String[] cName = new String[]{"序号", "类型", "时间", "单号", "状态", "班次", "班组", "操作员", "操作员编号"};

    public RtModel(List<Rt> data) {
        this.data = data;
    }

    @Override
    public int getRowCount() {
        return data.size();
    }

    @Override
    public int getColumnCount() {
        return cName.length;
    }

    @Override
    public String getColumnName(int column) {
        return cName[column];
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        Rt rt = data.get(rowIndex);
        if (columnIndex == 0) {
            return rowIndex + 1;
        } else if (columnIndex == 1) {
            return rt.getType();
        } else if (columnIndex == 2) {
            return rt.getTime();
        } else if (columnIndex == 3) {
            return rt.getCode();
        } else if (columnIndex == 4) {
            return rt.getStatus();
        } else if (columnIndex == 5) {
            return rt.getBc();
        } else if (columnIndex == 6) {
            return rt.getBz();
        } else if (columnIndex == 7) {
            return rt.getCzy();
        } else if (columnIndex == 8) {
            return rt.getCzybh();
        }
        return "";
    }
}
